<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of TablaDatos
 *
 * @author fisc
 */
class TablaDatos {
    var $dataArray;
    var $cabeceraTabla;
    var $nroOrden = 1;
    var $width=0;
    
    function crearTabla(){
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "100%";
        }else{
            //$width = "500px";
            $width = "80%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         ?>
        <table border="1" cellspacing="0" cellpadding="5" align="center" width="<?=$width?>">
            <?
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont ==0){
                        ?> <tr   class="tb2"  style="background-color: #c3d5fd;  font-weight: bold;"> <?
                         foreach ($this->cabeceraTabla as $a => $b) {
                            ?>  <td><?=$b?> </td>  <?
                        }
                        ?>   </tr>     <?
                    } 
                ?>   <tr class="tb">  
                            <td><?=  $this->nroOrden?></td><?
                foreach ($value as $k => $v) {
                    if($cont2>0){
                    ?>      <td><?=$v?> </td>      <?
                    }
                    $cont2++;
                }
                $cont2=0;
                ?>
                    <td>
                        <center>
                            <form name="fe<?=$value[0]?>"  id="fe<?=$value[0]?>"  method="POST" >
                                <input type="hidden" name="id" value="<?=$value[0]?>" />
                                <input type="hidden" name="xarea" value="<?=$_REQUEST["xarea"]?>" />
                                <input type="hidden" name="filtrod" value="<?=$_REQUEST["filtrod"]?>" />
                                <input type="hidden" name="f1" value="<?=$_REQUEST["f1"]?>" />
                                <input type="hidden" name="f2" value="<?=$_REQUEST["f2"]?>" />
                                <img src="images/png/edit.png" style="cursor: pointer;" onclick="return enviarFormulario('index2.php?seccion=<?=$_REQUEST["seccion"]?>&op=edit','attriaje','fe<?=$value[0]?>');" />
                            </form>
                        </center>
                    </td>
                    <? if($_REQUEST["seccion"]!="documento"){ ?>
                    <td>
                        <center>
                            <form name="fd<?=$value[0]?>"  id="fd<?=$value[0]?>"  method="POST" >
                                <input type="hidden" name="id" value="<?=$value[0]?>" />
                                <input type="hidden" name="xarea" value="<?=$_REQUEST["xarea"]?>" />
                                <input type="hidden" name="filtrod" value="<?=$_REQUEST["filtrod"]?>" />
                                <input type="hidden" name="f1" value="<?=$_REQUEST["f1"]?>" />
                                <input type="hidden" name="f2" value="<?=$_REQUEST["f2"]?>" />
                                <img src="images/png/trash.png" style="cursor: pointer;" onclick="return confirmarEstado('index2.php?seccion=<?=$_REQUEST["seccion"]?>&op=del','attriaje','fd<?=$value[0]?>');" />
                            </form>
                        </center>
                    </td>                    
                <?
                    }
                $cont++;
                $this->nroOrden++;
                ?>     </tr>    <?
                }
            ?>
        </table>
    <?
    } 
        
    function crearTabla2($w = false, $noevento=false){
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            $width = "650px";
        }else{
            $width = "500px";
        }
        
        if($w){
            $width = $w;
        }
        
         ?>
        <table border="1" cellspacing="0" cellpadding="5" align="center" width="<?=$width?>">
            <?
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont ==0){
                        ?> <tr style="background-color: #c3d5fd;  font-weight: bold;"> <?
                         foreach ($this->cabeceraTabla as $a => $b) {
                            ?>  <td><?=$b?> </td>  <?
                        }
                        ?>   </tr>     <?
                    }
                    if($noevento){                        
                    ?>   
                        <tr class="tb" style="cursor: pointer;" >  
                    <?
                    }else{
                        ?>
                        <tr class="tb" style="cursor: pointer;" onclick="return enviarFormulario('index2.php?seccion=<?=$_REQUEST["seccion"]?>&op=status','atsistradoc3','fe<?=$value[0]?>');" >  
                        <?
                    }
                            ?>
                            <td><?=  $this->nroOrden?></td><?
                foreach ($value as $k => $v) {
                    if($cont2>0){
                    ?>                                  
                    <td><?=$v?> 
                            <form name="fe<?=$value[0]?>"  id="fe<?=$value[0]?>"  method="POST" >
                                <input type="hidden" name="id" value="<?=$value[0]?>" />                                
                            </form>                    
                    </td>      <?
                    }
                    $cont2++;
                }
                $cont2=0;  
                    
                $cont++;
                $this->nroOrden++;
                ?>     </tr>    <?
                }
            ?>
        </table>
    <?
    }
    
    function crearTabla3($w = false){
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            $width = "650px";
        }else{
            $width = "500px";
        }
        
        if($w){
            $width = $w;
        }
        
         ?>
        <table border="1" cellspacing="0" cellpadding="5" align="center" width="<?=$width?>">
            <?
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont ==0){
                        ?> <tr style="background-color: #c3d5fd;  font-weight: bold;"> <?
                         foreach ($this->cabeceraTabla as $a => $b) {
                            ?>  <td><?=$b?> </td>  <?
                        }
                        ?>   </tr>     <?
                    } 
            ?>   <tr class="tb" style="cursor: pointer;" onclick="return showExtra('tr<?=$this->nroOrden?>','fe<?=$value[0]?>','index2.php?seccion=<?=$_REQUEST["seccion"]?>&op=showfollow');" >  
                            <td><?= $this->nroOrden?></td><?
                foreach ($value as $k => $v) {
                    if($cont2>0){
                    ?>                                  
                    <td><?=$v?> 
                            <form name="fe<?=$value[0]?>"  id="fe<?=$value[0]?>"  method="POST" >
                                <input type="hidden" name="id" value="<?=$value[0]?>" />                                
                            </form>                    
                    </td>      <?
                    }
                    $cont2++;
                }
                
                ?>     </tr>

                        <tr class="tb" style="cursor: pointer; display: none;" onclick="return hideExtra('tr<?=$this->nroOrden?>');" id="tr<?=$this->nroOrden?>">  
                            <td colspan="<?=count($this->cabeceraTabla)?>">
                                <div id="divtr<?=$this->nroOrden?>"></div>
                            </td>
                        </tr>
                <?
                
                $cont2=0;  
                    
                $cont++;
                $this->nroOrden++;
                }
            ?>
        </table>
    <?
    }
    
    function crearTablaClientes(){
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "100%";
        }else{
            //$width = "500px";
            $width = "80%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         ?>
        <table border="1" cellspacing="0" cellpadding="5" align="center" width="<?=$width?>">
            <?
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont ==0){
                        ?> <tr   class="tb2"  style="background-color: #c3d5fd;  font-weight: bold;"  > <?
                         foreach ($this->cabeceraTabla as $a => $b) {
                            ?>  <td><?=$b?> </td>  <?
                        }
                        ?>   </tr>     <?
                    } 
                 ?>   <tr class="tb">  
                            <td><?=  $this->nroOrden?></td><?
                foreach ($value as $k => $v) {
                    if($cont2>0){
                        ?>      <td onclick="return openDetalle('<?=$value[0]?>');" style="cursor: pointer;" ><?=$v?> </td>      <?
                    }
                    $cont2++;
                }
                $cont2=0;
                ?>
                    <td>
                        <center>
                            <form name="fe<?=$value[0]?>"  id="fe<?=$value[0]?>"  method="POST" >
                                <input type="hidden" name="id" value="<?=$value[0]?>" />
                                <input type="hidden" name="xarea" value="<?=$_REQUEST["xarea"]?>" />
                                <input type="hidden" name="filtrod" value="<?=$_REQUEST["filtrod"]?>" />
                                <input type="hidden" name="f1" value="<?=$_REQUEST["f1"]?>" />
                                <input type="hidden" name="f2" value="<?=$_REQUEST["f2"]?>" />
                                <img src="images/png/edit.png" style="cursor: pointer;" onclick="return enviarFormulario('index2.php?seccion=<?=$_REQUEST["seccion"]?>&op=edit','attriaje','fe<?=$value[0]?>');" />
                            </form>
                        </center>
                    </td>
                    <? if($_REQUEST["seccion"]!="documento"){ ?>
                    <td>
                        <center>
                            <form name="fd<?=$value[0]?>"  id="fd<?=$value[0]?>"  method="POST" >
                                <input type="hidden" name="id" value="<?=$value[0]?>" />
                                <input type="hidden" name="xarea" value="<?=$_REQUEST["xarea"]?>" />
                                <input type="hidden" name="filtrod" value="<?=$_REQUEST["filtrod"]?>" />
                                <input type="hidden" name="f1" value="<?=$_REQUEST["f1"]?>" />
                                <input type="hidden" name="f2" value="<?=$_REQUEST["f2"]?>" />
                                <img src="images/png/trash.png" style="cursor: pointer;" onclick="return confirmarEstado('index2.php?seccion=<?=$_REQUEST["seccion"]?>&op=del','attriaje','fd<?=$value[0]?>');" />
                            </form>
                        </center>
                    </td>                    
                <?
                    }
                $cont++;
                $this->nroOrden++;
                ?>     </tr>    <?
                }
            ?>
        </table>
    <?
    } 
    
    function crearTablaClienteFrame(){
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "100%";
        }else{
            //$width = "500px";
            $width = "80%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         ?>
        <table border="0" cellspacing="0" cellpadding="5" align="center" width="<?=$width?>">
            <?
              foreach ($this->dataArray as $key => $value) {
                    if($cont ==0 ){
                        ?> <tr   class="tb2"  style="background-color: #c3d5fd;  font-weight: bold;"> <?
                         foreach ($this->cabeceraTabla as $a => $b) {
                            ?>  <td><?=$b?> </td>  <?
                        }
                        ?>   </tr>     <?
                    } 
                    ?>   <tr class="tb" style="cursor:pointer;" onclick="return asignarClienteAlServicio('<?=$value[0]?>');">  
                            <td><?=  $this->nroOrden?></td><?
                foreach ($value as $k => $v) {
                    $cump ="";
                    if($cont2>0 && $cont2 != 8){
                        if($cont2 == 1){
                            if(substr(convertirFechatoNormal($value[8]),0,5) == date('d-m')) {$cump= "<img src='images/png/crown.png' title='CUMPLEA&Ntilde;OS' alt='CUMPLEA&Ntilde;OS' /> sa";}
                    ?>      <td><?=$cump."  ".$v?> </td>      <?
                        } else {
                    ?>      <td><?=$v?> </td>      <?        
                        }
                    }
                    $cont2++;
                }
                $cont2=0;
?>
                
                 
                <?
                $cont++;
                $this->nroOrden++;
                ?>     </tr>    <?
                }
            ?>
        </table>
    <?
    }
    
    function crearTablaServicios(){
        include_once 'funciones.php';
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "80%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         ?>
        <table border="1" cellspacing="0" cellpadding="5" align="center" width="<?=$width?>" id="tablaServicio">
            <?
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont ==0){
                        ?> <tr   class="tb2"  style="background-color: #c3d5fd;  font-weight: bold;"> <?
                         foreach ($this->cabeceraTabla as $a => $b) {
                            ?>  <td><?=$b?> </td>  <?
                        }
                        ?>   </tr>     <?
                    } 
                ?>   <tr class="tb">  
                            <td><?=  $this->nroOrden?></td><?
                foreach ($value as $k => $v) {
                    if($cont2>0 && $cont2 != 4 && $cont2 != 5 && $cont2 != 8){
                    ?>      <td><?=$v?> </td>      <?
                    } else {
                        if ( $cont2>0 && $cont2 == 4 ) {
                            ?>      <td><?=convertirFechatoNormal($v)?> </td>      <?
                        } else {
                            if ( $cont2 == 5 ) {
                            ?>      <td><?=convertirFechatoNormal($v)." ". substr($v, 10) ?> </td>      <?
                            } else {
                                if ( $cont2 == 8 ) {
                                ?>      <td> <font color=red> <?=$v?> </font> </td>      <?
                                }
                            }
                        }
                    }
                    $cont2++;
                }
                $cont2=0;
                ?>
                    
        <td onclick="return pagos('<?=$value[0]?>');" style="cursor: pointer;" 
            title="REALIZAR PAGO!" alt="REALIZAR PAGO!" >
            <center>                    
                <img src="images/png/money.png" style="cursor: pointer;"  />
            </center>
        </td>

        <td onclick="return ticket('<?=$value[0]?>');" style="cursor: pointer;" 
            title="IMPRIMIR TICKET!" alt="IMPRIMIR TICKET!" >
            <center>                    
                <img src="images/png/vcard.png" style="cursor: pointer;"  />
            </center>
        </td>

        <td onclick="return boleta('<?=$value[0]?>');" style="cursor: pointer;" 
            title="IMPRIMIR BOLETA!" alt="IMPRIMIR BOLETA!" >
            <center>
                <img src="images/png/print2.png" width="18" style="cursor: pointer;"  />
            </center>
        </td>   
        
     <!--   <td onclick="return cambioEstado('<?=$value[0]?>');" style="cursor: pointer;" 
            title="CAMBIAR ESTADO!" alt="CAMBIAR ESTADO!" >
            <center>
                <img src="images/png/wand.png" width="18" style="cursor: pointer;"  />
            </center>
        </td>   
        
        <td onclick="return retirarPrendas('<?=$value[0]?>');" style="cursor: pointer;" 
            title="RETIRAR PRENDAS!" alt="RETIRAR PRENDAS!" >
            <center>
                <img src="images/png/tag_blue.png" width="16" style="cursor: pointer;"  />
            </center>
        </td>     -->
                <?                    
                $cont++;
                $this->nroOrden++;
                ?>     </tr>    <?
                }
            ?>
        </table>
    <?
    } 

    
    function crearTablaServiciosPdf(){
        include_once 'funciones.php';
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "80%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         
        $t .= '<table border="1" cellspacing="0" cellpadding="2" align="center" width="'.$width.'" id="tablaServicio">';
            
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont == 0){
                        $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }
                        $t .= '  </tr>  ';
                    } 
                $t .= '  <tr >  ';
                 $t .= '      <td> '. $this->nroOrden .' </td> ';
                foreach ($value as $k => $v) {
                    if($cont2>0 && $cont2 != 4 && $cont2 != 5 && $cont2 != 8){
                        $t .= '   <td>'.$v.' </td>  ';
                        if($cont2==7){
                            $cta += $v;
                        }
                        if($cont2==6){
                            $total += $v;
                        }
                    } else {
                        if ( $cont2>0 && $cont2 == 4 ) {
                            $t .= '  <td>'.convertirFechatoNormal($v).' </td> ';
                        } else {
                            if ( $cont2 == 5 ) {
                            $t .= '  <td>'.convertirFechatoNormal($v).' '. substr($v, 10) .' </td> ';
                            } else {
                                if ( $cont2 == 8 ) {
                                    $t .= '  <td> <font color=red> '.($v).' </font> </td> ';
                                    $saldo += $v;
                                }
                            }
                        }
                    }
                    $cont2++;
                }
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';
                }
                $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                             if ($a==6) {
                                 $t .= ' <td> '.number_format($total,2).' </td> ';
                             } else {
                                 if ($a==7) {
                                    $t .= ' <td> '.number_format($cta,2).' </td> ';
                                } else {
                                    if ($a==8) {
                                        $t .= ' <td> '.number_format($saldo,2).' </td> ';
                                    } else {
                                        if ($a==5) {
                                            $t .= ' <td> TOTAL: </td> ';
                                        } else {
                                            $t .= ' <td>  </td> ';
                                        }
                                    }
                                }
                             }
                        }
                        $t .= '  </tr>  ';
      $t .= '  </table> ';
      
      return $t;
    } 
        
    function creatTablaTrabajosDelDia(){
             include_once 'funciones.php';
             include_once 'conexionMysql.php';
             
        $DB = new conexionMysql();
        $DB->ConectarBD();          
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "90%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
              
      $t .= '<center><div id=test> ';
      $t .= '</div></center> ';
        
      $t .= '<form id=formu name=formu > ';
         
        $t .= '<table border="1" cellspacing="0" cellpadding="0" align="center" width="'.$width.'" id="tablaServicio">';
            
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont == 0){
                        $t .= ' <tr style="background-color:#c3d5fd ;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }                        
                        $t .= '  </tr>  ';
                    }                
                $t .= '  <tr >  ';
                 $t .= '      <td><b> '. $this->nroOrden .' </b></td> ';
                foreach ($value as $k => $v) {
                    if($cont2>0 && $cont2 != 2 && $cont2 != 4){
                        $t .= '   <td>'.$v.' </td>  ';
                    } else {
                        if ( $cont2>0 && $cont2 == 2 ) {
                            $t .= '  <td>'.convertirFechatoNormal($v).' </td> ';
                        } else {
                            if ( $cont2 == 4 ) {
                                if ($_REQUEST["frame"]=="pdf") { 
                                    if ($v==0) {
                                            $t .= '      <td>  </td>     '; 
                                    }  else {
                                            $t .= '      <td align=center> <img src="images/png/check.png" /> </td>     '; 
                                    }                                     
                                } else {
                                    if ($v==0) {
                                            $t .= '      <td>  ';
                                            $t .= '          <center>  ';
                                            $t .= '              <input type=checkbox name="check[]" value="'.$value[0].'" />  ';
                                            $t .= '          </center>  ';
                                            $t .= '      </td>     '; 
                                    }  else {
                                            $t .= '      <td>  ';
                                            $t .= '          <center>  ';
                                            $t .= '              <input type=checkbox checked=checked  name="check[]" value="'.$value[0].'" />  ';
                                            $t .= '          </center>  ';
                                            $t .= '      </td>     '; 
                                    }                                     
                                }                        
                            }
                        }
                    }
                    $cont2++;     
                    $q = "";
                    $rse = "";
                    
                    $q = " select b_estado from boleta where `td_id` ='".$this->b_id."' " ;
                   // $rse = $DB->ObtenerData($q); 
        
        
                }

                
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';                
                
                $t .= '  <tr>   ';
                $t .= '  <td>   ';
                $t .= '  </td>   ';
                
                $t .= '  <td>  TIP. SERV ';
                $t .= '  </td>   ';
                $t .= '  <td> PRENDA  ';
                $t .= '  </td>   ';
                $t .= '  <td>  CANTIDAD ';
                $t .= '  </td>   ';
                 $t .= '  <td>  DETALLE / <b>CINT.COLOR</b> ';
                $t .= '  </td>   ';
                
                
                $t .= '  </tr>   ';
                              
                
                
                
                $qq = " select  "
                . " serv_nombre, p_nombre, bp_cantidad, concat (bp_observacion,' / ',bp_color) "               
                . " from boleta, boleta_prenda, prenda, servicio "
                . " where bp_b_id = b_id "
                . " and bp_p_id = p_id "
                . " and bp_s_id = serv_id "
                . " and b_correlativo = '".$value[1]."' ";
                
                //include_once 'recursos/conexionMysql.php';
                //$DB = new conexionMysql();
                $rr = $DB->ObtenerData($qq);
                
                //var_dump($rr);
                
                foreach ($rr as $key => $value) {
                    
                    $t .= '  <tr>   ';               
                    $t .= '  <td>   ';
                    $t .= '  </td>   ';
                                        
                    $t .= '  <td>   ';
                    $t .=  $value[0];
                    $t .= '  </td>   ';
                    
                    $t .= '  <td>   ';
                    $t .=  $value[1];
                    $t .= '  </td>   ';
                    
                    $t .= '  <td>   ';
                    $t .=  $value[2];
                    $t .= '  </td>   ';
                    
                    $t .= '  <td>   ';
                    $t .=  $value[3];
                    $t .= '  </td>   ';
                    
                                       
                    $t .= '  </tr>   ';
                }
                
                
                $t .= '  <tr>   ';
                $t .= '  <td colspan=5 >   ';
                $t .= '  </td>   ';
                                
                $t .= '  </tr>   ';
                
                }
//                
      $t .= '  </table> ';
      
      $t .= '</form> ';
      
      return $t;   
    }
    
    function creatTablaTrabajosDelDia2(){
             include_once 'funciones.php';
             include_once 'conexionMysql.php';
             
        $DB = new conexionMysql();
        $DB->ConectarBD();          
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "80%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
              
      $t .= '<center><div id=test> ';
      $t .= '</div></center> ';
        
        //$t .= '<form id=formu name=formu > ';
         
        $t .= '<table border="1" cellspacing="0" cellpadding="0" align="center" width="'.$width.'" id="tablaServicio">';
            
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont == 0){
                        $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }
                        $t .= '  </tr>  ';
                    } 
                $t .= '  <tr onclick="return modal2(\''.$value[0].'\');" style="cursor:pointer;" >  ';
                 $t .= '      <td> '. $this->nroOrden .' </td> ';
                foreach ($value as $k => $v) {
                    if($cont2>0 && $cont2 != 2){
                        $t .= '   <td>'.$v.' </td>  ';
                    } else {
                        if ( $cont2>0 && $cont2 == 2 ) {
                            $t .= '  <td>'.convertirFechatoNormal($v).' </td> ';
                        }
                    }
                    $cont2++;     
                    $q = "";
                    $rse = "";
                }

                
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';
                }
      $t .= '  </table> ';
      
     // $t .= '</form> ';
      
      return $t;   
    }
    
    function creaInformeCajaDiaPdf(){
             include_once 'funciones.php';
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "80%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         
        $t .= '<table border="1" cellspacing="0" cellpadding="2" align="center" width="'.$width.'" id="tablaServicio">';
            
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont == 0){
                        $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }
                        $t .= '  </tr>  ';
                    } 
                $t .= '  <tr >  ';
                 $t .= '      <td> '. $this->nroOrden .' </td> ';
                foreach ($value as $k => $v) {
                    if($cont2>0 ){
                        $t .= '   <td>'.$v.' </td>  ';
                        if($cont2==2){
                            $total += $v;
                        }
                    } 
                    $cont2++;
                }
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';
                }
                $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                     foreach ($this->cabeceraTabla as $a => $b) {
                        if ($a==1) {
                            $t .= ' <td> TOTAL: </td> ';
                        } else {
                            if ($a==2) {
                                $t .= ' <td> '.number_format($total,2).'  </td> ';
                            } else {
                                $t .= ' <td>  </td> ';
                            }
                        }                            
                    }
                        $t .= '  </tr>  ';
      $t .= '  </table> ';
      
      return $t;   
    }
        
    function creaClientesDeudoresPdf(){
             include_once 'funciones.php';
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "90%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         
        $t .= '<table border="1" cellspacing="0" cellpadding="2" align="center" width="'.$width.'" id="tablaServicio">';
            $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
            $t .= ' <td colspan="'.(count($this->cabeceraTabla)).'" > CLIENTES QUE NO HAN REALIZADO NINGUN PAGO </td> ';
            $t .= '  </tr>  ';
              foreach ($this->dataArray as $key => $value) {     
                  if ($value[5]==0) {
                    if($cont == 0){
                        $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }
                        $t .= '  </tr>  ';
                    } 
                $t .= '  <tr >  ';
                 //$t .= '      <td> '. $this->nroOrden .' </td> ';
                foreach ($value as $k => $v) {
                    
                        if ($cont2<5) {
                            if ($cont2==3) {
                                $total += $v;
                                $t .= '   <td> <font color=red > <b>'.$v.'</b> </font> </td>  ';
                            } else {
                                $t .= '   <td>'.$v.' </td>  ';
                            }
                        }
                    
                    $cont2++;
                }
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';
                }
              }
                $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                     foreach ($this->cabeceraTabla as $a => $b) {
                        if ($a==2) {
                            $t .= ' <td> TOTAL: </td> ';
                        } else {
                            if ($a==3) {
                                $t .= ' <td> '.number_format($total,2).'  </td> ';
                            } else {
                                $t .= ' <td>  </td> ';
                            }
                        }                            
                    }
                        $t .= '  </tr>  ';
      $t .= '  </table> ';
              $total =0;
      $t .= '  <br/><br/> ';
      
      
      $t .= '<table border="1" cellspacing="0" cellpadding="2" align="center" width="'.$width.'" id="tablaServicio">';
            $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
            $t .= ' <td colspan="'.(count($this->cabeceraTabla)).'" > CLIENTES QUE HAN REALIZADO POR LO MENOS 1 PAGO </td> ';
            $t .= '  </tr>  ';
            $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                     foreach ($this->cabeceraTabla as $a => $b) {
                         $t .= ' <td> '.$b.' </td> ';
                     }
            $t .= '  </tr>  ';
              foreach ($this->dataArray as $key => $value) {     
                  if ($value[5]>0) {
                    if($cont == 0){
                        $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }
                        $t .= '  </tr>  ';
                    } 
                $t .= '  <tr >  ';
                 //$t .= '      <td> '. $this->nroOrden .' </td> ';
                foreach ($value as $k => $v) {
                    
                        if ($cont2<5) {
                            if ($cont2==3) {
                                $total += $v;
                                $t .= '   <td> <font color = red > <b>'.$v.'</b> </font> </td>  ';
                            } else {
                                $t .= '   <td>'.$v.' </td>  ';
                            }
                        }
                    
                    $cont2++;
                }
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';
                }
              }
                $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                     foreach ($this->cabeceraTabla as $a => $b) {
                        if ($a==2) {
                            $t .= ' <td> TOTAL: </td> ';
                        } else {
                            if ($a==3) {
                                $t .= ' <td> '.number_format($total,2).'  </td> ';
                            } else {
                                $t .= ' <td>  </td> ';
                            }
                        }                            
                    }
                        $t .= '  </tr>  ';
      $t .= '  </table> ';
      
      
      return $t;   
    }
       
    function creaInventarioPrendasPdf(){
              
        include_once 'funciones.php';
        include_once 'conexionMysql.php';
             
        $DB = new conexionMysql();
        $DB->ConectarBD();
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "90%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
         
        $t .= '<table border="1" cellspacing="0" cellpadding="2" align="center" width="'.$width.'" id="tablaServicio">';

                //$t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont == 0){
                        $t .= ' <tr style="background-color:#c3d5fd; font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }                        
                        $t .= '  </tr>  ';
                    }                
                $t .= '  <tr >  ';
                
                foreach ($value as $k => $v) {
                    if($cont2>0 && $cont2<>5){
                        
                        $t .= '   <td>'.$v.' </td>  ';
                        
                    } else {
                        if ( $cont2>0 && $cont2 == 5) {
                            $t .= '  <td>'.convertirFechatoNormal($v).' </td> ';
                        } 
                    } 
                    $cont2++;     
                    $q = "";
                    $rse = "";

                }

                
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';                
                
                $t .= '  <tr>   ';
                $t .= '  <td>   ';
                $t .= '  </td>   ';
                
                $t .= '  <td>  TIP. SERV ';
                $t .= '  </td>   ';
                $t .= '  <td> PRENDA(S)  ';
                $t .= '  </td>   ';
                $t .= '  <td>  CANTIDAD ';
                $t .= '  </td>   ';
                 $t .= '  <td>  DETALLE ';
                $t .= '  </td>   ';
                $t .= '  <td>   ';
                $t .= '  </td>   ';
                
                $t .= '  </tr>   ';
                
                
                
                
                $qq = " select  "
                . " serv_nombre, p_nombre, bp_cantidad, bp_observacion"
                . " from boleta, boleta_prenda, prenda, servicio "
                . " where bp_b_id = b_id "
                . " and bp_p_id = p_id "
                . " and bp_s_id = serv_id "
                . " and b_correlativo = '".$value[1]."' ";
                
                
                $rr = $DB->ObtenerData($qq);
                
                //var_dump($rr);
                
                foreach ($rr as $key => $value) {
                    
                    $t .= '  <tr>   ';               
                    $t .= '  <td>   ';
                    $t .= '  </td>   ';
                                        
                    $t .= '  <td>   ';
                    $t .=  $value[0];
                    $t .= '  </td>   ';
                    
                    $t .= '  <td>   ';
                    $t .=  $value[1];
                    $t .= '  </td>   ';
                    
                    $t .= '  <td>   ';
                    $t .=  $value[2];
                    $t .= '  </td>   ';
                    
                    $t .= '  <td>   ';
                    $t .=  $value[3];
                    $t .= '  </td>   '; 
                    
                    $t .= '  <td>   ';
                    $t .= '  </td>   ';
                                       
                    $t .= '  </tr>   ';
                }
                
                
                $t .= '  <tr>   ';
                $t .= '  <td colspan="6" >   ';
                $t .= '  </td>   ';
                                
                $t .= '  </tr>   ';
                
                }

      $t .= '  </table> ';
      
      return $t;
        
    }
    
    function creaInformePrendasPdf(){
                include_once 'funciones.php';
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "90%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         
        $t .= '<table border="1" cellspacing="0" cellpadding="2" align="center" width="'.$width.'" id="tablaServicio">';

                $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                foreach ($this->cabeceraTabla as $a => $b) {
                    $t .= ' <td> '.$b.' </td> ';
                }
                $t .= '  </tr>  ';
                        
              foreach ($this->dataArray as $key => $value) {
                $t .= '  <tr >  ';
                 //$t .= '      <td> '. $this->nroOrden .' </td> ';
                foreach ($value as $k => $v) {
                    if ($cont > 0 && $cont2 ==0){
                        if ($this->dataArray[$key-1][0] != $value[0] ){
                            $t .= ' <td colspan="6"> &nbsp; </td>   </tr> <tr> ';
                        }
                        
                    }
                    if($cont2>0 ){
                        if ($this->dataArray[$key-1][0] == $value[0] && $cont2 <=3 ){
                            $t .= ' <td></td> ';
                        } else {
                            if ($v == "0000-00-00 00:00:00") {
                                $t .= ' <td> </td>';
                            } else {
                                $t .= ' <td>'.$v.' </td>';
                            }
                        }
                    }
                    $cont2++;
                }
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';
                }
                $t .= '  </tr>  ';
      $t .= '  </table> ';
      
      return $t;   
        
    }
    
    function crearTablaPdf(){
        include_once 'funciones.php';
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "80%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         
        $t .= '<table border="1" cellspacing="0" cellpadding="2" align="center" width="'.$width.'" id="tablaServicio">';
            
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont == 0){
                        $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }
                        $t .= '  </tr>  ';
                    } 
                $t .= '  <tr >  ';
                 $t .= '      <td> '. $this->nroOrden .' </td> ';
                foreach ($value as $k => $v) {
                    if($cont2>0){
                        $t .= '   <td>'.$v.' </td>  ';
                        if($cont2==7){
                            $cta += $v;
                        }
                        if($cont2==6){
                            $total += $v;
                        }
                    } 
                    $cont2++;
                }
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';
                }
                $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                             if ($a==6) {
                                 $t .= ' <td> '.number_format($total,2).' </td> ';
                             } else {
                                 if ($a==7) {
                                    $t .= ' <td> '.number_format($cta,2).' </td> ';
                                } else {
                                    if ($a==8) {
                                        $t .= ' <td> '.number_format($saldo,2).' </td> ';
                                    } else {
                                        if ($a==5) {
                                            $t .= ' <td> TOTAL: </td> ';
                                        } else {
                                            $t .= ' <td>  </td> ';
                                        }
                                    }
                                }
                             }
                        }
                        $t .= '  </tr>  ';
      $t .= '  </table> ';
      
      return $t;
    } 
    
    function crearTablaPdf2(){
        include_once 'funciones.php';
        
        if(isset ($_REQUEST["li"])){
            $this->nroOrden=$_REQUEST["li"]+1;
        }
        
        if(isset($_REQUEST["page"])){
            $this->nroOrden = ($_REQUEST["page"]*10)-9;
        }        
        $cont = 0;
        $cont2 = 0;
        
        if(count($this->cabeceraTabla)>6){
            //$width = "650px";
            $width = "99%";
        }else{
            //$width = "500px";
            $width = "95%";
        }
        
        if($this->width>0){
            $width = " ".$this->width." ";
        }
        
         
        $t .= '<table border="1" cellspacing="0" cellpadding="2" align="center" width="'.$width.'" id="tablaServicio">';
            
              foreach ($this->dataArray as $key => $value) {                                                       
                    if($cont == 0){
                        $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                            $t .= ' <td> '.$b.' </td> ';
                        }
                        $t .= '  </tr>  ';
                    } 
                $t .= '  <tr >  ';
                 $t .= '      <td> '. $this->nroOrden .' </td> ';
                foreach ($value as $k => $v) {
                    if($cont2>0){
                        $t .= '   <td>'.$v.' </td>  ';
                        if($cont2==7){
                            $cta += $v;
                        }
                        if($cont2==5){
                            $total += $v;
                        }
                    } 
                    $cont2++;
                }
                $cont2=0;                   
                $cont++;
                $this->nroOrden++;
                $t .= '  </tr>   ';
                }
                $t .= ' <tr style="background-color: #c3d5fd;  font-weight: bold;"> ';
                         foreach ($this->cabeceraTabla as $a => $b) {
                             if ($a==5) {
                                 $t .= ' <td> '.number_format($total,2).' </td> ';
                             } else {
                                 if ($a==7) {
                                    $t .= ' <td> '.number_format($cta,2).' </td> ';
                                } else {
                                    if ($a==8) {
                                        $t .= ' <td> '.number_format($saldo,2).' </td> ';
                                    } else {
                                        if ($a==4) {
                                            $t .= ' <td> TOTAL: </td> ';
                                        } else {
                                            $t .= ' <td>  </td> ';
                                        }
                                    }
                                }
                             }
                        }
                        $t .= '  </tr>  ';
      $t .= '  </table> ';
      
      return $t;
    } 
    
    
    
    function setDataArray($dataTotal){
        $this->dataArray = $dataTotal;
    } 
    function getDataArray(){
        return $this->dataArray;
    }   
    
    function setCabeceraTabla($dataCabecera){
        $this->cabeceraTabla = $dataCabecera;
    }         
    function getCabeceraTabla(){
        return $this->cabeceraTabla;
    }    
}